function Squ(x,y,color){
    this.x=x;
    this.y=y;
    this.color=color;
    this.realX=x*10;
    this.realY=y*10;
    this.filled=false;
    this.canvas=document.createElement('canvas');
    // this.render();
    this.nearSqu=[];

    this.No1=false;
}

Squ.prototype={
    len:10,
    setNear:function(){
        if(!squList){
            return;
        }
        var m=0;
        var nearList=[
            getSqu(this.x-1,this.y-1),getSqu(this.x,this.y-1),getSqu(this.x+1,this.y-1),
            getSqu(this.x-1,this.y),getSqu(this.x+1,this.y),
            getSqu(this.x-1,this.y+1),getSqu(this.x-1,this.y+1),getSqu(this.x+1,this.y+1)
        ];
        for(var i=0;i<nearList.length;i++){
            if(nearList[i]!=""){
                this.nearSqu.push(nearList[i]);
                m++
            }
        }
        this.nearSqu.length=m;
    },
    render:function(){
        
        this.canvas.width=10;
        this.canvas.height=10;
        var ctx=this.canvas.getContext('2d');
        
        ctx.fillStyle=this.color;
        ctx.fillRect(0,0,this.len,this.len);
        ctx.strokeStyle='#8e8e8e';
        ctx.rect(0,0,10,10);
        ctx.stroke();
    },
    invalid:function(){
        if(this.x<0||this.y<0||this.x>MAX_X||this.y>MAX_Y){
            return true;
        }else{
            return false;
        }
    },
    nearFilled:function(){
        this.setNear();
        for(var i=0;i<this.nearSqu.length;i++){
            if(this.nearSqu[i].filled){
                return true;
            }
        }
        return false;
    },
    farFilled:function(){
        this.setNear();
         for(var i=0;i<this.nearSqu.length;i++){
            if(this.nearSqu[i].nearFilled()){
                return true;
            }
        };
        return false;
    }
}